# -*- coding: utf-8 -*-
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
from dajie.items import DajieItem

class DajieDyxSpider(CrawlSpider):
    name = 'dajie_dyx'
    allowed_domains = ['dajie.com']
    start_urls = ['http://dajie.com/job']
    custom_settings = {
        "DEFAULT_REQUEST_HEADERS": {
            "accept": "application / json, text / javascript, * / *;q = 0.01",
            "accept-encoding": "gzip, deflate, br",
            "accept-language": "zh - CN, zh;q = 0.9",
            "referer: https": "// www.dajie.com /",
            "user-agent": "Mozilla / 5.0(WindowsNT10.0;WOW64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 74.0.3702.0Safari / 537.36",
            "x-requested-with": "XMLHttpRequest",
            'cookie': 'DJ_RF = http % 3A % 2F % 2Fwww.so.com % 2Flink % 3Fm % 3DahpteyCXTjISwF1w % 252B50N3pSx % 252B6Pp % 252Fv5vUo0NezP4TG2BnoBSfYmHrj7YeleY3Emn3 % 252B1vvhO0HstQgoF3q46Sc4CWYc4RwR6R1;DJ_EU = http % 3A % 2F % 2Fwww.dajie.com % 2F;DJ_UVID = MTU1MjM3MjAyMDExNTA1NTAy;_ga = GA1.2.341624554.1552372020;_gid = GA1.2.1772163980.1552372020;Hm_lvt_6822a51ffa95d58bbe562e877f743b4f = 1552372020;_close_autoreg = 1552372073597;_close_autoreg_num = 4;USER_ACTION = "request^A-^A-^Ajobdetail:^A-";_ssytip = 1552374638686;redir = http % 3A % 2F % 2Fjob.dajie.com % 2Fjob % 2Fsearch % 3FpositionFunction % 3D % 5Cs;_gat_gtag_UA_117102476_1 = 1;Hm_lpvt_6822a51ffa95d58bbe562e877f743b4f = 1552377189',
        }
    }


    rules = (
        Rule(LinkExtractor(allow=r'/search?positionFunction=\d'),callback='parse', follow=True),
        Rule(LinkExtractor(allow=r'/\w+.html'), callback='parse_list',follow=False),
    )
    def parse(self, response):
        print(response.url)
        # pass

    def parse_list(self, response):
        # print(response.text)
        pass

